#coding:utf-8
import requests
import time
import demjson
while True:
    try:
        url = 'http://45.32.120.142:5000/status'
        res = requests.get(url)
        json = demjson.decode(res.text)
        if json['TaskStatusInfo']['status'] == 'STOP':
            time.sleep(600)
            res = requests.post('http://45.32.100.28:5000/addTask',data={
                'name':'utmtoken',
                'taskinfo':'''{ 	'charset': 'utf-8', 	'AllowRedirects': 'False', 	'ContainList': ['CenterVoucherHandler'], 	'ExcludeList': ['cloudflare', 'cfduid'], 	'Headers': "{'Host': 'www.utmtoken.com','User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.101 Safari/537.36 QQBrowser/4.3.4986.400','Connection':'close'}", 	'Path': '/js/czjl.js', 	'SSL': 'False', 	'ScanType': 'GET', 	'Thread': 300, 	'TimeOut': 1, }'''
            })
            print('retry:',res.text)
            time.sleep(600)
    except Exception as e:
        time.sleep(600)